

public class demo8 {
    public static void main(String[] args) {
        Thread t1=new Thread(()->{
            for (int i = 0; i < 5; i++) {
                System.out.println(Thread.currentThread().getName()+"----"+i);
                if(i==3){
                    System.out.println("线程让步：");
                    Thread.yield();
                }
            }
        });
        Thread t2=new Thread(()->{
            for (int i = 0; i < 5; i++) {
                System.out.println(Thread.currentThread().getName()+"----"+i);
                if(i==3){
                    System.out.println("线程让步：");
                    Thread.yield();
                }
            }
        });

        t1.start();
        t2.start();
    }
}
